package com.learn.training.multithread.chapter6.minchapter1.demo5;

public class Demo5 {
    public static void main(String[] args) {
        var c1 = new  Counter();
        var c2 = new  Counter();

        //对c1进行操作
        new Thread(() -> {
            c1.add(1);
        }).start();

        new Thread(() -> {c1.dec(1);}).start();

        //对c2进行操作
        new Thread(() -> {c2.add(1);}).start();
        new Thread(() -> {c2.dec(1);}).start();
        System.out.println("c1  : " + c1.get());
        System.out.println("c2  : " + c2.get());
    }
}
